#ifndef GLOBAL_H
#define GLOBAL_H
#include "flit_queue.h"

typedef enum {IDLE, BUSY} voq_stat_type; 
typedef enum {BERN, POIS} traffic_type; //Traffic type: bernoulli/poisson
typedef enum {UNIF, HOTS, TRAN} traffic_pattern; //Traffic patter: uniform/hotspot

//Network parameters
extern unsigned int NUM_NODES      ; 
extern unsigned int NUM_CHN        ; 
extern unsigned int CHN_FLY_TIME   ; 
extern double       CHN_PHASE      ; 
extern unsigned int NUM_FLT_TO_INJ ; 
extern double       INJ_RATE       ; 
extern unsigned int INJ_BUF_DEPTH  ; 
extern unsigned int EJT_BUF_DEPTH  ; 
extern unsigned int SWITCH_PROC_DLY; 
extern unsigned int FRAME_SZ       ; 
extern unsigned int MAX_REQS       ;
extern unsigned int MAX_ACCS       ;
extern unsigned int IDL_LAT        ; 
extern traffic_type TRA_TYPE       ; 
extern traffic_pattern TRA_PATTERN ; 
extern unsigned int STAT_INTV      ;
extern bool QOS                    ; 
extern bool VERBOSE                ;

//Stat counters 
extern unsigned int num_ejt_flits; 
extern unsigned int num_inj_flits;
extern double       total_flit_latency;
extern double       average_flit_latency; 
extern double       accepted_throughput;
extern unsigned int *node_throughputs;
extern double       dyn_o_power;
extern double       dyn_e_power;
extern double       laser_power; 
extern double       ring_heating_power; 
extern unsigned int tot_jitter;
extern unsigned int tot_jitter_var; 
extern unsigned int num_jitter; 
extern unsigned int *bin_jitter; 

//Global simulator status 
extern unsigned int SRC_CLK      ;
extern unsigned int DLY_TAP_PT   ; 
extern bool         SIM_END_FLAG ;
 
//Maps
extern unsigned int **node_pri_map;
extern unsigned int **chn_map;

//Queues
extern flit_queue_t **inj_queues; 
extern flit_queue_t  *ejt_queues;

//Request and token vector
extern unsigned int **requests; 
extern unsigned int *token;
extern unsigned int *last_requested; 
extern unsigned int *last_used; 

//Flit delay tap to emulate the flight time latency
extern flit_t ***flt_dly_tap;

//Completion counter
extern unsigned int      *comp_counter;
extern voq_stat_type     **voq_stat; 

//Used for frame-based QOS
extern int **alloc_res;
extern int **curr_res;

//Used to "guess" if a node is idle
extern unsigned int **last_busy_cycle; 
#endif
